package Control;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import View.VStart;
/**
 * Steuerung der View Start
 * 
 * @author Niklas Wazal
 * @version 1.1.3 - 09.09.2014
 */
public class CStart {

	public static CStart instance = null;
	public VStart viewStart;
	public CStartDialog startDialog = CStartDialog.getInstance();

	/**
	 * Erstellt Singleton
	 * 
	 * @return instance
	 */
	public static CStart getInstance() {
		if (instance == null) {
			instance = new CStart();
		}
		return instance;
	}

	/**
	 * Konstruktor
	 */
	public CStart() {
		this.viewStart = new VStart();

		init();
		registerEvents();

	}

	class MyMouseAdapter extends MouseAdapter {
		public void mouseClicked(MouseEvent event) {
			Object object = event.getSource();
			if (object.equals(viewStart.getBtn_neuesProtokoll())) {
				startDialog.reiterWechseln(1);
			}

			if (object.equals(viewStart.getBtn_suche())) {
				startDialog.reiterWechseln(5);
			}
		}

	}

	/**
	 * Registriert alle Events der StartView
	 */
	public void registerEvents() {
		MyMouseAdapter mouse = new MyMouseAdapter();

		viewStart.getBtn_neuesProtokoll().addMouseListener(mouse);
		viewStart.getBtn_suche().addMouseListener(mouse);

	}

	/**
	 * Initiale Methode
	 */
	public void init() {

		startDialog.reiterHinzufuegen("Start", viewStart);
	}

}
